<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="编号" prop="id">
        <el-input
          v-model="queryParams.id"
          placeholder="请输入客户编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="公司名称" prop="companyName">
        <el-input
          v-model="queryParams.companyName"
          placeholder="请输入客户公司名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="tableList" style="width: 100%;margin-top: 20px" border>
      <el-table-column label="客户编号" width="50" align="center" prop="id"/>
      <el-table-column label="公司名称"  align="center" prop="companyName"/>
      <el-table-column label="订单编号" width="110" align="center" prop="outTradeNo"/>
      <el-table-column label="订单创建时间" width="200" align="center" prop="createTime"/>
      <el-table-column label="收款方" align="center" prop="payee"/>
      <el-table-column label="服务项目" align="center" prop="serviceItem"/>
      <el-table-column label="价格（单位/元）" width="110" align="center" prop="total"/>
      <el-table-column label="操作" fixed="right" width="150" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
<!--          <el-button-->
<!--            size="mini"-->
<!--            type="text"-->
<!--            icon="el-icon-edit"-->
<!--            @click="handleUpdate(scope.row)"-->
<!--          >编辑-->
<!--          </el-button>-->
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
          >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      v-show="total>0"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :page-sizes="[2, 4, 6, 8]"
      :page-size="queryParams.pageSize"
      :current-page="queryParams.pageNum"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    >
    </el-pagination>


  </div>
</template>

<script>
export default {
  name: 'Paid',
  data() {
    return {
      total: 0,
      showSearch: true,
      queryParams: {
        curPage: 1,
        pageSize: 8,
      },
      form: {},
      tableList:[
        { id: 1 }
      ],
    }
  },
  created() {
    this.getTableList()
  },
  methods:{
    //获取未缴费列表
    getTableList() {
      this.request({
        url: '/order/getAllDdListByZ',
        method: 'post',
        params: this.queryParams
      }).then(res=>{
        console.log(res)
        if (res) {
          this.tableList = res.dataiNiuWangDetailsList
          this.total = res.totle
        }
      })
    },
    handleSizeChange(val) {
      this.queryParams.pageSize = val
      this.getTableList()
      console.log(`每页 ${val} 条`)
    },
    handleCurrentChange(val) {
      this.queryParams.curPage = val
      this.getTableList()
      console.log(`当前页: ${val}`)
    },
    handleUpdate(row) {

    },
    handleDelete(row) {
      this.$confirm('此操作将永久删除该订单, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.request({
          url: '/order/deleteDd',
          method: 'post',
          params: {
            outTradeNo: row.outTradeNo
          }
        }).then(res=>{
          console.log(res)
          if (res) {
            this.$message({
              type: 'success',
              message: '删除成功!'
            })
            this.getTableList()
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    handleQuery() {
      this.queryParams.curPage = 1
      this.getTableList()

    },
    resetQuery() {
      this.queryParams = {
        curPage: 1,
        pageSize: 8
      }
      this.handleQuery()
    }
  }
}
</script>

<style scoped>

</style>
